<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue基础</title>
</head>

<body>
  <div id="app">
    <!-- <button @click="toggleHandler">toggle</button> -->
    <button @click="awesome = !awesome">toggle</button>
    <!-- 页面初次加载就判断一次的用v-if -->
    <h1 v-if="awesome">Vue is awesome!</h1>
    <h1 v-else>Oh no 😢</h1>
    <!-- 频繁切换状态用v-show -->
    <h1 v-show="awesome">Vue is awesome!</h1>
    <h1 v-show="!awesome">Oh no 😢</h1>
    
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.7.8/dist/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        awesome: false
      },
      methods: {
        toggleHandler() {
          this.awesome = !this.awesome
          console.log(this.awesome);
        }
      }
    });


  </script>

</body>

</html>